<%@ Page Language="VB" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="false" CodeFile="Permissions.aspx.vb" Inherits="Admin_Permissions" title="Admin - Permissions" %>
<%@ Register Src="SubNavControls/RolePermissionsSubNavControl.ascx" TagName="RolePermissionsSubNavControl"
    TagPrefix="uc1" %>
<%@ Register Assembly="InputControls" Namespace="InputControls" TagPrefix="cc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">

<script language="javascript">
    function SelectAllCheckboxes(spanChk, columnType){

        var oItem = spanChk.children;
        var theBox = (spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];

        xState = theBox.checked;
        elm = theBox.form.elements;
        
        for(i=0;i<elm.length;i++)

            if(elm[i].type=="checkbox" && elm[i].id.indexOf(columnType) != -1 && elm[i].id!=theBox.id) {

                if(elm[i].checked!=xState)
                    elm[i].click();

            }

    }
</script>

<uc1:RolePermissionsSubNavControl ID="RolePermissionsSubNavControl1" runat="server" />

    <table cellpadding="0" cellspacing="0" border="0" style="width:870px;">
    <tr>
    <td style="width:20px"></td><td align="left" style="width:450px;"><h1><a id="pagecontent">Admin - Permissions</a></h1></td>
    <td style="width:400px;" align="right"><asp:Label ID="RoleLabel" runat="server" AssociatedControlID="RolesDropDownList" Text="Select Role:" CssClass="adminSelectLabel"></asp:Label>
        <asp:DropDownList ID="RolesDropDownList" runat="server" CssClass="adminSelectForm" DataSourceID="RolesObjectDataSource" DataValueField="RoleID" DataTextField="RoleDisplayName" AutoPostBack="false"></asp:DropDownList>
        <asp:Button runat="server" ID="SubmitRoleButton" Text="Go" />
        </td></tr>
    <tr><td colspan="3" align="center">
         <cc2:ScrollingGridView ID="PermissionsScrollingGridView" runat="server" CssClass="gridOffsetSmall" Width="700px" AutoGenerateColumns="False" Caption="Establish type of access to Participant file for each Role.  (Current Role: Participant)" CaptionAlign="Top" ToolTip="160"
            DataSourceID="RolePermissionsObjectDataSource" IsFixedColumn="true" DataKeyNames="RolePermissionID" CellPadding="4" BorderColor="#21334B" BorderStyle="Solid" 
            GridLines="Vertical" AllowSorting="true">
        <HeaderStyle  CssClass="adminHeaderStyle" BackColor="#C3CAD4" BorderColor="#21334B" VerticalAlign="Top" />
        <RowStyle CssClass="adminColumnStyle" />
        <Columns>
            <asp:TemplateField HeaderText="Application Module" SortExpression="PermissionId">
                 <ItemStyle Width="615px" />
                 <HeaderStyle Width="620px" />
                <ItemTemplate><%#DisplayPermission(Eval("PermissionId"))%>
                </ItemTemplate>
            </asp:TemplateField>
            
            <asp:TemplateField HeaderText="Read" ItemStyle-HorizontalAlign="center">
                <ItemTemplate>
                    <asp:CheckBox ID="ViewCheckBox" runat="server" Checked='<%#Eval("MayView")%>' />
                </ItemTemplate>
                <ItemStyle Width="80px" />
                <HeaderStyle Width="80px" />
                <HeaderTemplate>
                    Read<br />
                    <asp:CheckBox ID="ViewSelectAllCheckBox" runat="server" onclick="javascript:SelectAllCheckboxes(this, 'ViewCheckBox');" ToolTip="Select or De-select all"></asp:CheckBox>
                </HeaderTemplate>
            </asp:TemplateField>
            
            <asp:TemplateField HeaderText="Change" ItemStyle-HorizontalAlign="center">
                <ItemTemplate>
                    <asp:CheckBox ID="UpdateCheckBox" runat="server" Checked='<%#Eval("MayUpdate")%>'  />
                </ItemTemplate>
                <ItemStyle Width="80px" />
                <HeaderStyle Width="80px" />
                <HeaderTemplate>
                    Change<br />
                    <asp:CheckBox ID="UpdateSelectAllCheckBox" runat="server" onclick="javascript:SelectAllCheckboxes(this, 'UpdateCheckBox');" ToolTip="Select or De-select all"></asp:CheckBox>
                </HeaderTemplate>
            </asp:TemplateField>
            
            <asp:TemplateField HeaderText="Add" ItemStyle-HorizontalAlign="center">
                <ItemTemplate>
                    <asp:CheckBox ID="InsertCheckBox" runat="server" Checked='<%#Eval("MayInsert")%>' />
                </ItemTemplate>
                <ItemStyle Width="80px" />
                <HeaderStyle Width="110px" />
                <HeaderTemplate>
                    Add<br />
                    <asp:CheckBox ID="InsertSelectAllCheckBox" runat="server" onclick="javascript:SelectAllCheckboxes(this, 'InsertCheckBox');" ToolTip="Select or De-select all"></asp:CheckBox>
                </HeaderTemplate>
            </asp:TemplateField>
            
        </Columns>
        <AlternatingRowStyle BackColor="#E8ECF4" /></cc2:ScrollingGridView>
         </td></tr>
    </table>

        <asp:ObjectDataSource ID="RolesObjectDataSource" runat="server" SelectMethod="ListAll"
            TypeName="Cdm.DataCore.UserSecurity.Role" DataObjectTypeName="Cdm.DataCore.UserSecurity.Role" UpdateMethod="UpdateInstance" InsertMethod="SaveInstance">
        </asp:ObjectDataSource>

        <asp:ObjectDataSource ID="PermissionsObjectDataSource" runat="server" SelectMethod="Retrieve"
            TypeName="Cdm.DataCore.UserSecurity.Permission" DataObjectTypeName="Cdm.DataCore.UserSecurity.Permission" UpdateMethod="UpdateInstance" InsertMethod="SaveInstance">
            <SelectParameters>
                <asp:ControlParameter ControlID="PermissionsScrollingGridView" Name="ID" Type="int32" />
            </SelectParameters>
        </asp:ObjectDataSource>

        <asp:ObjectDataSource ID="RolePermissionsObjectDataSource" runat="server" SelectMethod="ListByRoleIdSort" SortParameterName="sortExpr"
            TypeName="Cdm.DataCore.UserSecurity.RolePermission" DataObjectTypeName="Cdm.DataCore.UserSecurity.RolePermission" UpdateMethod="UpdateInstance" InsertMethod="SaveInstance">
            <SelectParameters>
                <asp:ControlParameter ControlID="RolesDropDownList" PropertyName="SelectedValue" Name="RoleID" DefaultValue="" Type="int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
    
</asp:Content>
<asp:Content ID="FixedContentSection" runat="server" ContentPlaceHolderID="ContentPlaceHolderFixedAdmin">
    <asp:Button ID="SaveButton" runat="server" Text="Save" />
    <asp:Button ID="ResetButton" runat="server" Text="Reset" />
</asp:Content>

